package com.chenfeng.common.interceptor;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.chenfeng.users.pojo.AAdmins;
import com.chenfeng.users.service.IUserService;
@Component("adminsAuthIntercertor")
public class AdminsAuthIntercertor extends  HandlerInterceptorAdapter
{
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception
	{
		HttpSession session = request.getSession();
		AAdmins admins = (AAdmins)session.getAttribute("admins");
		if(admins!=null)
		{
			return true;
		}
		String info = "请先登录";
		session.setAttribute("info", info);
		//重定向到初始页面
		response.sendRedirect(request.getContextPath()+"/adminsLogin.htm");
		return false;
	}
	
}
